#include<iostream>
using namespace std;
typedef struct
{
	int h1;
	int h2;
	int sum;
}T;
T s[7];
int main()
{
	int count = 0;
	int max = -100;
	for (int i = 0; i < 7; i++) {
		cin >> s[i].h1;
		cin >> s[i].h2;
		s[i].sum = s[i].h1 + s[i].h2;
		if (s[i].sum > 8) {
			count++;
		}
		if (max < s[i].sum) {
			max = s[i].sum;
		}
	}
	if (count == 0) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < 7; i++) {
		if (max == s[i].sum) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}